using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SpringWaterDataAccess;

namespace sow
{
    public partial class typingentry : System.Web.UI.Page
    {
        protected int authorID = 0;
        protected string writingID = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            authorID = Convert.ToUInt16(Request.QueryString["authorID"]);
            writingID = Request.QueryString["writingID"];

            // Put user code to initialize the page here
            if (!IsPostBack)
            {
                ForumDataAccess da = new ForumDataAccess();

                DataTable dt = da.GetForumCategories(11).Tables[0];

                DropDownList_Category.DataSource = dt;
                DropDownList_Category.DataTextField = "CategoryName";
                DropDownList_Category.DataValueField = "CategoryID";
                DropDownList_Category.SelectedValue = "44";

                DropDownList_Category.DataBind();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            server.TypingServiceDataUtil da = new server.TypingServiceDataUtil();
            int CategoryID = Convert.ToUInt16(DropDownList_Category.SelectedValue);
            int SourcePostID = 3;
            int ReturnID = 0;
            decimal newWritingId;

            decimal newAuthorId = da.InsertAuthor(TextBox_Email.Text,
                            TextBox_FirstName.Text,
                            TextBox_LastName.Text,
                            TextBox_Address.Text,
                            TextBox_City.Text,
                            TextBox_State.Text,
                            TextBox_Country.Text,
                            TextBox_ZipCode.Text,
                            TextBox_Phone.Text,
                            TextBox_Fax.Text,
                            TextBox_Church.Text,
                            TextBox_RecommendBy.Text
                           );
            if (newAuthorId >= 0)
            {
                Response.Write("New Author Added with new Id = " + newAuthorId.ToString());

                newWritingId = da.InsertWriting(newAuthorId,
                TextBox_Title.Text,
                CategoryID,
                1,
                1,
                DateTime.Now,
                "A",
                "B",
                "C"
               );
            }
            else
            {
                Response.Write("New Author not added " );
            }
            return;
        }
    }
}
